{% extends "base.html" %}
{% block javascript %}
    <script>
        $(document).ready(function(){
            $("#button").click(function(){
                var num = $("#num").val();
                var is_get = $("#is_get").val();
                var data_post = $("#data_post").val();
                if (is_get == 1 && data_post == '') {
                    sweetAlert("", "POST请求需要填写POST数据", "info");
                    return false;
                }
                if (num == ''){
                    sweetAlert("", "数量不能为空,请填写数量", "info");
                    return false;
                }

            });
        });
    </script>
{% endblock %}
{% block main %}
        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h3 class="page-header">
                            接口发射器
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i>  <a href="../index">Dashboard</a>
                            </li>
                            <li>
                                <i class="fa fa-briefcase"></i>  <a>Test Tools</a>
                            </li>
                            <li class="active">
                                <i class="fa fa-delicious"></i> 接口发射器
                            </li>
                        </ol>
                    </div>
                </div>
                <div class="row" style="min-height: 500px;">
                    <div class="col-lg-12" style="text-align: left">
{#                            <P><b>注:</b>无需鉴权或者对鉴权对账号没有要求用户名和密码可以为空</P>#}
                            <form method= 'get'>
                                <br>
                                <div class="col-sm-3">
                                <select name="is_online" id="is_online" class="form-control" style=" width: 100%">
                                    <option value=1>线上环境</option>
                                    <option value=0>测试环境</option>
                                </select>&nbsp;&nbsp;
                                <input name="num" id="num" class="input-sm" style="width: 40%; margin-left: -10px; margin-top: 10%" placeholder="数量">&nbsp;&nbsp;线上/测试({{ count_online }}/{{ count_test }})
                                </div>
                                <div class="col-sm-3">
                                <select name="is_get" id="is_get" class="form-control" style="width: 100%">
                                    <option value=1>POST请求</option>
                                    <option value=0>GET请求</option>
                                </select>&nbsp;&nbsp;
                                </div>
                                <div class="col-sm-6">
                                    <input name="data_post" id="data_post" class="input-sm" style="width: 60%;" placeholder="POST数据">&nbsp;&nbsp;选择POST选项,该项必填
                                </div>
                                <div class="col-sm-9">
                                    <input name="url" id="url" class="input-sm" style="width: 30%;" placeholder="请输入URL" >&nbsp;&nbsp;
                                    <input name="gest_uid" id="gest_uid" class="input-sm" style="width: 10%;margin-left: 3%" placeholder="个数">&nbsp;&nbsp;变量个数
                                    <input type="submit" id="button" name="button" class="btn btn-info" style="width: 10%" value="确定"/>&nbsp;&nbsp;
                                </div>
                            </form>
                            <br>
                            <div style="text-align: left; margin-top: 9%; margin-left: 1.5%" >
                                <p style="position:relative;width: 100%;height:auto; overflow-x:auto;">
                                   <h4>运行结果:</h4><br>
                                    <textarea class="form-control"  style="width: 100%;min-height: 100px; text-align: left">{{ result }}
                                    </textarea>
                                </p>
                            </div>
                            <div class="table-responsive">
                                <h4 style="margin-left: 1.5%">历史操作记录:</h4><br>
                                <table class="table table-hover table-striped" style="height:8px;">
                                    <thead>
                                        <tr>
                                            <th class="col-lg-1" style="text-align: center">#</th>
                                            <th class="col-lg-1" style="text-align: center">环境</th>
                                            <th class="col-lg-1" style="text-align: center">请求</th>
                                            <th class="col-lg-6" style="text-align: center">请求url</th>
                                            <th class="col-lg-1" style="text-align: center">数量</th>
                                            <th class="col-lg-2" style="text-align: center">时间</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        {% for show in history_list.object_list %}
                                            <tr>
                                                <td style="text-align: center;vertical-align:middle">{{ show.id }}</td>
                                                {% if show.is_online == 1 %}
                                                <td style="text-align: center;vertical-align:middle">线上</td>
                                                {% else %}
                                                <td style="text-align: center;vertical-align:middle">测试</td>
                                                {% endif %}
                                                {% if show.is_post == 1 %}
                                                <td style="text-align: center;vertical-align:middle">POST</td>
                                                {% else %}
                                                <td style="text-align: center;vertical-align:middle">GET</td>
                                                {% endif %}
                                                <td style="text-align: left;vertical-align:middle">{{ show.url }}</td>
                                                <td style="text-align: center">{{ show.number }}</td>
                                                <td style="text-align: center">{{ show.time }}</td>
                                            </tr>
                                        {% empty %}
                                            <tr>
                                                暂无用户
                                            </tr>
                                        {% endfor %}
                                    </tbody>
                                </table>
                                <div class="row col-lg-12" style="text-align: center">
                                    <span class="step-links">
                                        <ul class="pager">
                                         {% if history_list.has_previous %}
                                         <li class="prev">
                                             <a href="?page={{ history_list.previous_page_number }}" class="previous">上一页</a>
                                         </li>
                                         {% endif %}
                                         第 {{ history_list.number }}/{{ history_list.paginator.num_pages }} 页
                                         {% if history_list.has_next %}
                                             <li class="prev">
                                                 <a href="?page={{ history_list.next_page_number }}">下一页</a>
                                             </li>
                                         {% endif %}
                                            <li class="next"><a>共{{ history.count }}条</a></li>
                                        </ul>
                                    </span>
                                </div>
                        </div>

{#                                        {% endif %}#}
                    </div>
                </div>

        </div>

        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="../static/js/jquery.js"></script>
    <script src="../static/js/sweet-alert.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../static/css/sweet-alert.css">

    <!-- Bootstrap Core JavaScript -->
    <script src="../static/js/bootstrap.min.js"></script>
{% endblock %}

</body>

</html>
